package com.example.hellomap;

import java.lang.reflect.Field;

import com.example.hellomap.MainActivity;

import android.support.v4.widget.DrawerLayout;
import android.test.ActivityInstrumentationTestCase2;

/**
 * 
 * @author Alle
 */
public class Test_MainActivity extends  ActivityInstrumentationTestCase2<MainActivity>  {
	
	MainActivity myMain;
	MyGoogleMap 	myMap;	// kell egy terkep amit tesztelunk
	
	public Test_MainActivity() {
		super(MainActivity.class);
	}	
	
    @Override
    protected void setUp() throws Exception {

        super.setUp();
        myMain = getActivity();
        myMap = myMain.getMymap();
    }	
	
	public void test_MyMapShouldBeNotNull() {
		
		assertNotNull( myMain.getMymap() );		
	}
    
	public void test_mDrawerShouldBeNotNull() {
		
		assertNotNull( myMain.getmDrawerLayout() );		
	}
	
	public void test_mDrawerListShouldBeNotNull() {
		
		assertNotNull( myMain.getmDrawerList() );		
	}
	
	// lazy reflection 
	public void test_is_mDrawer_SetCorrectly() throws NoSuchFieldException {
		
		Field listener = DrawerLayout.class.getDeclaredField("mListener");
		listener.setAccessible(true);
		
		assertNotNull(listener);
	}
	
	public void test_is_mDrawerList_SetCorrectly() {

		assertNotNull( myMain.getmDrawerList().getAdapter() );	
		assertNotNull( myMain.getmDrawerList().getOnItemClickListener() );	
	}
	
	public void test_isViewSet() {
		
		assertNotNull(myMain.findViewById(android.R.id.content));		
	}

}
